<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>

<html>
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
    <title>微购商城</title>
    <link href="${pageContext.request.contextPath}/static/css/css.css" rel="stylesheet" type="text/css"/>
    <script src="${pageContext.request.contextPath}/static/js/jquery.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/js/js.js" type="text/javascript"></script>
</head>

<body>
<div class="mianCont">
    <%--指定引入页面--%>
    <%@include file="common/_top.jsp" %>
    <div class="pnt">
        <div class="pntLeft">
            <h2 class="Title">所有商品分类
                <%--指定引入页面--%>
                <%@include file="common/_menu.jsp" %>
            </h2>
        </div>
        <div class="pntRight">
            <ul class="nav">
                <li><a href="${pageContext.request.contextPath}/index">商城首页</a></li>
                <li><a href="${pageContext.request.contextPath}/goods/list?categoryId=${categoryList.get(0).key}">${categoryList.get(0).value}</a></li>
                <li class="navCur"><a href="login.jsp">会员中心</a></li>
                <li><a href="help.html">帮助中心</a></li>
                <div class="clears"></div>
                <div class="phone">TEL：13264494458</div>
            </ul>
        </div>
        <div class="clears"></div>
    </div>
    <div class="positions">
        当前位置：<a href="index.html">首页</a> &gt; <a class="posCur" href="#">订单详情</a>
    </div>

    <table class="orderList" style="margin-left: 20px;">
        <tr>
            <td>
                <span style="font-weight: bold;">编号：</span>${order.id}
            </td>
            <td>
                <span style="font-weight: bold;">用户姓名：</span>${order.userName}
            </td>
            <td>
                <span style="font-weight: bold;">支付方式：</span>${order.payMethodName}
            </td>
            <td colspan="2">
                <span style="font-weight: bold;">地址：</span>
                ${pccList.get(2).value} - ${pccList.get(1).value} - ${pccList.get(0).value} - ${order.addressName}
            </td>
        </tr>

        <tr>
            <td>
                <span style="font-weight: bold;">创建时间：</span>${fn:replace(order.createTime, 'T', ' ')}
            </td>
            <td>
                <span style="font-weight: bold;">更新时间：</span>${fn:replace(order.updateTime, 'T', ' ')}
            </td>
            <td>
                <span style="font-weight: bold;">数量：</span>${order.amount}
            </td>
            <td>
                <span style="font-weight: bold;">金额：</span>${order.money}
            </td>
            <td>
                <span style="font-weight: bold;">状态：</span>
                <span style="color: #ee3333">${ORDER_STATE_MAP.get(order.state)}</span>
            </td>
        </tr>
        <tr>
            <td colspan="5">
                <table class="orderList">
                    <tr>
                        <td>序号</td>
                        <td>商品图片</td>
                        <td>商品名称</td>
                        <td>商品卖点</td>
                        <td>价格</td>
                        <td>单位</td>
                        <td>数量</td>
                        <td>金额</td>
                    </tr>
                    <c:forEach items="${orderItemList}" var="orderItem" varStatus="vs">
                        <tr>
                            <td>${vs.count}</td>
                            <td>
                                <img src="${RESOURCES_SERVER}/goods/${orderItem.goodsPic}" alt="${orderItem.goodsPic}" style="width: 100px;">
                            </td>
                            <td>
                                <a href="${pageContext.request.contextPath}/manager/goods/details?id=${orderItem.goodsId}">${orderItem.goodsName}
                            </td>
                            <td>${orderItem.goodsSellingPoint}</td>
                            <td>${orderItem.goodsPrice}</td>
                            <td>${orderItem.goodsUnit}</td>
                            <td>${orderItem.amount}</td>
                            <td>${orderItem.money}</td>
                        </tr>
                    </c:forEach>
                </table>
            </td>
        </tr>
    </table>

    <%--指定引入页面--%>
    <%@include file="common/_bottom.jsp" %>
</div>

<script type="text/javascript">
    $(function () {
        //查询条件数据回显
        $("#state option[value=${orderQuery.state}]").attr("selected", true);
        $("#area option[value='${orderQuery.payMethodId}']").attr("selected", true);

        //修改状态or删除时弹出对话框
        if (${resultBean!= null  && resultBean.msg !=null}) {
            alert("${resultBean.msg}");
        }
    });

    //搜索
    function changesearch() {
        let stateValue = $("#state").val();
        let payMethodIdValue = $("#payMethodId").val();
        let keywordsValue = $("#keywords").val();
        let param = "state=" + stateValue + "&payMethodId=" + payMethodIdValue + "&keywords=" + keywordsValue;
        document.location.href = "${pageContext.request.contextPath}/manager/order/list?" + param;
    }

    //搜索文件输入框回车自动查询
    function search(event) {
        let keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
        //判断是否为回车键
        if (keyCode == 13) {
            changesearch();
        }
    }

    //修改状态
    function changeState(id, state) {
        //暂时模拟
        state = state === 1 ? 0 : 1;
        if (confirm("您确定要修改吗?")) {
            document.location.href = "${pageContext.request.contextPath}/manager/order/changeState?id=" + id + "&state=" + state;
        }
    }
</script>
</body>
</html>